/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */

export default function access(initialState: any) {
  const userMenusKeys = (initialState && initialState?.userMenusKeys) || [];
  const accessData = (initialState && initialState?.accessData) || {};

  return {
    ...accessData,
    ...{
      normalRouteFilter: (route: any) => {
        return userMenusKeys.includes(route.key);
      }
    },
  };
}
